package com.jyh.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSONObject;
import com.jyh.config.BaseAction;
import com.jyh.config.datasource.TargetDataSource;
import com.jyh.db.entity.JyhBankList;
import com.jyh.db.entity.JyhBankListExample;
import com.jyh.db.mapper.JyhBankListMapper;
import com.jyh.dbOrder.dao.LoanDao;
import com.jyh.util.StringUtils;

@Service
public class BorrowStateService extends BaseAction{
	@Autowired
	private LoanDao loanDao;
	
	/**
	 * 用户基本信息-查询order订单状态
	 */
	@TargetDataSource(name = "order")
	public String borrowState(String userNumber){
		String sqlOrder = "SELECT * FROM jyh_order WHERE userNO = '" + userNumber + "'";
		List<Map<String, Object>> order = loanDao.getListMap(sqlOrder);
		if (order !=null && order.size() > 0) {
			Map<String, Object> orderMap = order.get(order.size() - 1);
			if (orderMap !=null && orderMap.size() > 0) {
				String putState = orderMap.get("putState")+ "";
				String state = orderMap.get("state")+ "";
				if (state.equals("9")) {
					return "clear";	//已结清
				}
				if (putState.equals("2")) {
					return "put";	//已放款
				}
				return "order";		//已经生成订
			} else {
				return "null";
			}
		}
		return "null";
	}
}
